CorporateLicense = "企业证照"
ProductLicense = "产品证照"

TemplateName = "common_template"

LICENSE = "营业执照"
YPSCXKZ = "药品生产许可证"
YPJYXKZ = "药品经营许可证"
YLQXSCXKZ = "医疗器械生产许可证"
YLQXJYXKZ = "医疗器械经营许可证"
YLQXSCBAPZ = "医疗器械生产备案凭证"
YLQXJYBAPZ = "医疗器械经营备案凭证"
YPZCZ = "药品注册批件"
YLQXZCZ = "医疗器械注册证"
YLQXBAZ = "医疗器械备案证"


MAPPING_STRUCTURE = [
    {
        "certificateType": CorporateLicense,
        "certificateName": LICENSE,
        "templateName": TemplateName,
        "subCertificateName": "(企业法人|个体工商户|个人独资企业)?营业执照?",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative", "certificateValidity"],
        "optionalFields": ["businessScope", "issueDate"]
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YPSCXKZ,
        "templateName": TemplateName,
        "subCertificateName": "药品生.{0,2}许可证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YPJYXKZ,
        "templateName": TemplateName,
        "subCertificateName": "药品经.{0,2}许可证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YLQXSCXKZ,
        "templateName": TemplateName,
        "subCertificateName": "医疗器械生.{0,2}许可证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YLQXJYXKZ,
        "templateName": TemplateName,
        "subCertificateName": "医疗器械经.{0,2}许可证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YLQXSCBAPZ,
        "templateName": TemplateName,
        "subCertificateName": ".*医疗器.{0,2}生.{0,2}备案凭证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": CorporateLicense,
        "certificateName": YLQXJYBAPZ,
        "templateName": TemplateName,
        "subCertificateName": ".*医疗器.{0,2}经.{0,2}备案凭证",
        "requiredFields": ["supplierName", "certificateCode", "legalRepresentative",
                           "certificateValidity", "businessScope"],
        "optionalFields": ["issueDate"],
    },
    {
        "certificateType": ProductLicense,
        "certificateName": YPZCZ,
        "templateName": TemplateName,
        "subCertificateName": "药品注册批件",
        "requiredFields": ["manufacturer", "certificateCode", "certificateValidity"],
        "optionalFields": ["supplierName", "productName", "productSpecification", "issueDate", "productValidity",
                           "registerRepresentative", "productAddress", "dosageForm", "structComposition",
                           "registerAddress", "applicationScope", "legalRepresentative"],
    },
    {
        "certificateType": ProductLicense,
        "certificateName": YLQXZCZ,
        "templateName": TemplateName,
        "subCertificateName": ".*医疗器械注册证",
        "requiredFields": ["manufacturer", "certificateCode", "certificateValidity"],
        "optionalFields": ["supplierName", "productName", "productSpecification", "issueDate", "productValidity",
                           "registerRepresentative", "productAddress", "dosageForm", "structComposition",
                           "registerAddress", "applicationScope", "legalRepresentative"],
    },
    {
        "certificateType": ProductLicense,
        "certificateName": YLQXBAZ,
        "templateName": TemplateName,
        "subCertificateName": ".*医疗器械备案(凭)?证",
        "requiredFields": ["manufacturer", "certificateCode", "certificateValidity"],
        "optionalFields": ["supplierName", "productName", "productSpecification", "issueDate", "productValidity",
                           "registerRepresentative", "productAddress", "dosageForm", "structComposition",
                           "registerAddress", "applicationScope", "legalRepresentative"],
    },
]

COMMON_FIELDS = {
    "supplierName": "^([余企]业|公司|字号|单位|经营者)?[名称](.*)",
    "certificateCode": "^([绵证]号|.{0,3}编号|.{0,2}号:)(.*)",
    "certificateValidity": "(有效期至|注册证有效.{0,2}至|(授权|营业|发证|经营|许可)?(期限|有效期限|有效期))(.*)",
    "businessScope": "^(.{0,10}范围|经营范.{0,2}|经营.{0,2}围)(.*)",
    "issueDate": "^((颁发|登记|备案|发证)日.{0,1}|(批准|审批)部门)(.*)",
    "legalRepresentative": "^(法定代[表吃]人|姓名|负责人|经营者|法定代表)(.*)",
    "manufacturer": "^(药品生产企业|.{0,2}厂(名称|家))(.*)",
    "productName": "^(药品.{0,3}名称|产.{0,1}名称|.{0,1}品名称)(.*)",
    "productSpecification": "^(规格|型号)(.*)",
    "productValidity": "^(药品)?有效期(.*)",
    "registerRepresentative": "^注册人(名称|姓名)(.*)",
    "registerAddress": "^注册人(住所)(.*)",
    "productAddress": "^(([生差]产|经[骨营])(范围|地址|场所)|生产地.{0,20})(.*)",
    "dosageForm": "^剂型(.*)",
    "structComposition": "^(主要)?结构及组成(.*)",
    "applicationScope": "[圣适]用范围(.*)",
    "createDate": "成立日期(.*)",
}

